<%@ tag language="java" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/layouts/include/taglib.jsp" %> 

<%@ attribute name="name" required="true" %>
<%@ attribute name="dataUrl" required="false" %>
<%@ attribute name="type" required="true" %>
<%@ attribute name="optionValue" required="false" %>
<%@ attribute name="optionName" required="false" %>
<%@ attribute name="id" required="true" %>
<%@ attribute name="css" required="false" %>
<%@ attribute name="style" required="false" %>
<%@ attribute name="onchange" required="false" %>
<%@ attribute name="placeholder" required="false" %>
<%@ attribute name="otherParams" required="false" %>
<%@ attribute name="required" required="false" %>
<%@ attribute name="defVal" required="false" %>
<%@ attribute name="hasBlank" required="false" %>
<%@ attribute name="createDoc" required="false" %>



<c:if test="${empty optionValue}">
	<c:set var="optionValue" value="codeNo"></c:set>
	
</c:if>

<c:if test="${empty optionName}">
	<c:set var="optionName" value="codeName"></c:set>
	
</c:if>
<c:if test="${empty dataUrl}">
	<c:set var="dataUrl" value="/sys/code/queryCodeInfo.do"></c:set>
	
</c:if>


<script type="text/javascript">
	
	Otod.ajax({
		url : "${ctx}${dataUrl}",
		data : "${type}",
		successFn:function(data){
			var html = new StringBuffer();
			<c:if test="${not empty hasBlank}">
				html.append("<option value=\"\">").append("请选择").append("</option>");
			</c:if>
			
			for(var i=0;i<data.length;i++){
				html.append("<option value=\"").append(data[i].${optionValue}).append("\" ");
				if("${defVal}"==data[i].${optionValue}){
					html.append("selected=\"selected\"");
				}
				html.append(" >").append(data[i].${optionName}).append("</option>");
			}
			
			<c:if test="${not empty createDoc}">
				html.append("<option value=\"\">").append("创建文档").append("</option>");
			</c:if>
			$("#"+"${id}").html(html.toString());
		}
	});

</script>

	<select class="form-control select2" id="${id }"  name="${name }" required="${required }"  css="${css }" style="${style }"  onchange="${onchange }" placeholder="${placeholder}" ${otherParams}>
							
</select>